package com.asura.app.library.imageload;

import android.graphics.drawable.Drawable;

/**
 * Created by Asura on 2017/11/29.
 */
public class ImageLoadOptions {
    public static final int UNKNOW = 0;
    public static final int ORIGIN = 1;
    private String url;
    private String path;
    private int resId;
    private Drawable placeHolder;
    private Drawable error;
    private int width;
    private int height;
    private Priority priority;
    private boolean memoryCache;
    //    private boolean diskCache;
    private String thumbnail;

    private ImageLoadOptions(Builder builder) {
        url = builder.url;
        path = builder.path;
        resId = builder.resId;
        placeHolder = builder.placeHolder;
        error = builder.error;
        width = builder.width;
        height = builder.height;
        priority = builder.priority == null ? Priority.NORMAL : builder.priority;
        memoryCache = builder.memoryCache;
        thumbnail = builder.thumbnail;
    }


    public String getUrl() {
        return url;
    }

    public String getPath() {
        return path;
    }

    public int getResId() {
        return resId;
    }


    public Drawable getPlaceHolder() {
        return placeHolder;
    }

    public Drawable getError() {
        return error;
    }

    public int getWidth() {
        return width;
    }

    public int getHeight() {
        return height;
    }

    public Priority getPriority() {
        return priority;
    }

    public boolean isMemoryCache() {
        return memoryCache;
    }

    public String getThumbnail() {
        return thumbnail;
    }

    public static final class Builder {
        private String url;
        private String path;
        private int resId;
        private Drawable placeHolder;
        private Drawable error;
        private int width = UNKNOW;
        private int height = UNKNOW;
        private Priority priority;
        private boolean memoryCache = true;
        private String thumbnail;

        public Builder() {
        }

        public Builder url(String url) {
            this.url = url;
            return this;
        }

        public Builder path(String path) {
            this.path = path;
            return this;
        }

        public Builder resId(int resId) {
            this.resId = resId;
            return this;
        }

        public Builder placeHolder(Drawable placeHolder) {
            this.placeHolder = placeHolder;
            return this;
        }

        public Builder error(Drawable error) {
            this.error = error;
            return this;
        }

        public Builder width(int width) {
            this.width = width;
            return this;
        }

        public Builder height(int height) {
            this.height = height;
            return this;
        }

        public Builder priority(Priority priority) {
            this.priority = priority;
            return this;
        }

        public Builder memoryCache(boolean memoryCache) {
            this.memoryCache = memoryCache;
            return this;
        }

        public Builder thumbnail(String thumbnail) {
            this.thumbnail = thumbnail;
            return this;
        }

        public ImageLoadOptions build() {
            return new ImageLoadOptions(this);
        }
    }
}
